package com.lwj.liwanjia.view.activity.dianpu;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.adapter.ShopClassifyAdapter;
import com.lwj.liwanjia.base.BaseActivity;
import com.lwj.liwanjia.utils.PopUtils;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;
import com.superrecycleview.superlibrary.recycleview.SuperRecyclerView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ShopClassifyActivity extends BaseActivity {

    @BindView(R.id.tv_left)
    TextView tvLeft;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_right)
    ImageView ivRight;
    @BindView(R.id.rlv_shangpin)
    SuperRecyclerView rlvShangpin;

    private List<String> list = new ArrayList<>();
    private ShopClassifyAdapter adapter;

    @Override
    protected void initView() {
        tvLeft.setVisibility(View.VISIBLE);
        ivRight.setVisibility(View.VISIBLE);
        ivRight.setImageResource(R.mipmap.fenlei);
        tvTitle.setText("商品分类");
        LinearLayoutManager manager = new LinearLayoutManager(this);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        rlvShangpin.setLayoutManager(manager);
        rlvShangpin.setRefreshEnabled(false);
        rlvShangpin.setLoadMoreEnabled(false);
        adapter = new ShopClassifyAdapter(this, list);
        rlvShangpin.setAdapter(adapter);
        listener();
    }

    private void listener() {
        adapter.setOnItemClickListener(new SuperBaseAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, Object item, int position) {
                Intent intent = new Intent(ShopClassifyActivity.this, ShopDetailActivity.class);
                startActivity(intent);
            }
        });
    }

    @Override
    protected void initData() {
        list.add("休闲食品");
        list.add("水产生鲜");
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_shop_classify;
    }

    @OnClick({R.id.tv_left, R.id.iv_right, R.id.rl_all})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_left:
                finish();
                break;
            case R.id.iv_right://分类
                PopUtils.getInstance().showPopupWindow(this, ivRight);
                break;
            case R.id.rl_all://所有商品
                Intent intent = new Intent(ShopClassifyActivity.this, ShopDetailActivity.class);
                startActivity(intent);
                break;
        }
    }
}
